package priv.lirenhe.dissertation.component.data_parser.content_parser;

import java.util.List;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class WebContentToTextParser {
	private String webContent;
	
	public WebContentToTextParser(String webContent){
		this.webContent = webContent;
	}
	
	public String getContentInText(){
		String contentText = null;
		try{
			Document document = Jsoup.parse(this.webContent);
			contentText = document.text();
		}catch(Exception e){
			e.printStackTrace();
		}
		return contentText;
	}
	
	public String getContentTitle(){
		Element titleEle = null;
		String title = null;
		try{
			Document document = Jsoup.parse(this.webContent);
			titleEle = document.select("title").first();
			if(titleEle != null){
				title = titleEle.text();
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return title;
	}
	
}
